// 发布者
class Dep{
    constructor(){
        // 存储所有观察者
        this.watchers = []
    }

    addSub(watcher){
        if(watcher && watcher.update) this.watchers.push(watcher)
    }

    notify(){
        this.watchers.forEach(watcher =>{
            watcher.update()
        })
    }
}